package flyshoes.controller;

import flyshoes.mybatis.entity.PageQueryResult;
import flyshoes.mybatis.entity.Result;
import flyshoes.query.ShoesQuery;
import flyshoes.service.ItemServiceImpl;
import io.lettuce.core.dynamic.annotation.Param;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/item")
public class ItemController {
    private final ItemServiceImpl itemService;

    @GetMapping("/getAllCategory")
/**获取分类列表*/
    public Result getAllCategory() {
        return itemService.getAllCategory();
    }

    @GetMapping("/{cateId}/getShoesByCateId")
/**根据分类id获取商品*/
    public Result getShoesBycateId(@PathVariable Integer cateId) {
        return itemService.getShoesBycateId(cateId);
    }

    @GetMapping("{productId}/getOneShoes") //根据productId获取一个商品
    public Result getOneShoes(@PathVariable Integer productId) {
        return itemService.getOneShoes(productId);
    }

    @GetMapping("/getShoesByName")
    public Result getShoesByName(String productName){
        return itemService.getShoesByName(productName);
    }

    @GetMapping("/queryShoes")  //根据条件查询和筛选商品
    public Result queryShoes(ShoesQuery shoesQuery) {
        return itemService.queryShoes(shoesQuery);
    }

}
